<?php

namespace app\common\model\other;
use think\Model;
use fast\Tree;
class NewspapersCategory extends Model
{

    

    

    // 表名
    protected $name = 'newspapers_category';


    public function getCreatetimeAttr($value)
    {
        $status = date('Y-m-d', $value);
        return $status;
    }

    public function newspapers(){
        return $this->hasMany('newspapers','category_id');
    }


    /**
     * 读取指定ID下子分类
     * @param string $type   指定类型
     * @param string $status 指定状态
     * @return array
     */
    public static function getList()
    {

        $list=collection(self::where(['status'=>'normal'])->with(['newspapers'=>function($query){
            $query->where('status','=','normal');
            $query->order('weigh desc');
        }])->order('weigh', 'desc')->select())->toArray();

        return $list;
    }





}
